package cn.kgc.pojo.vo;

import java.io.Serializable;

public class Result<T> implements Serializable {
    private static final  long serialVersionUID=2750226997856224667L;
    private Integer code;//返回码，0表示成功
    private String msg;//返回码的描述
    private Integer count;//分页的总记录数
    private int totalPage;
    private T data;//返回的数据

    private Result(){
        this.code=0;
        this.msg="success";
    }
    private Result(int totalPage,Object data){
        this.code=0;
        this.count=totalPage;
        this.msg="success";
        this.data=(T)data;
    }
    private Result(Integer code, String msg){
        this.code=code;
        this.msg=msg;
    }
    private Result(Integer count, Object data){
        this.code=0;
        this.msg="success";
        this.count=count;
        this.data=(T)data;
    }

    public  static Result<Object> success(){

        return new Result<Object>();
    }
    public  static Result<Object> success(Integer count, Object data){

        return new Result<Object>(count,data);
    }
    public  static Result<Object> success(int totalPage,Object data){

        return new Result<Object>(totalPage,data);
    }

    public  static Result<Object> fail(Integer code, String msg){

        return new Result<Object>                                                                                                                                                                                             (code,msg);
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Integer getCount() {
        return count;
    }

        public void setCount(Integer count) {
        this.count = count;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "Result{" +
                "code=" + code +
                ", msg='" + msg + '\'' +
                ", count=" + count +
                ", totalPage=" + totalPage +
                ", data=" + data +
                '}';
    }
}
